package com.google.code.expr.lang;

import com.google.code.expr.runtime.EXPRRunTimeState;
import com.google.code.expr.runtime.EXPRValue;
import com.google.code.expr.runtime.EXPRValueConverter;

public class EXPRConstNumber extends EXPRConst {

	private EXPRValue mNumber;
	
	public EXPRConstNumber(String pNumber) throws ParseException {
		try {
			mNumber = new EXPRValue(EXPRValueConverter.parseNumber(pNumber));
		} catch (java.text.ParseException e) {
			throw new ParseException("Error parsing number "+pNumber+" line "+getLineNumber()+" and column "+getColumn());
		}
	}
	
	public String toString() {
		return mNumber.toString();
	}
	
	@Override
	public String resolveToString(EXPRRunTimeState pState) {
		return mNumber.resolveAsString();
	}

	@Override
	public EXPRValue resolveToValue(EXPRRunTimeState pState) {
		return mNumber;
	}

}
